#include<stdio.h>  
#include<easyx.h>
#include<graphics.h>
#include<Windows.h>
#include<mmsystem.h>
#include<math.h>
#pragma comment(lib,"winmm.lib")
int p = 0;
int map[20][20] = { 0 };
void initGame()//游戏准备工作
{
	initgraph(700, 500); //绘制游戏窗口

	setbkcolor(RGB(115, 251, 253));
	cleardevice();//设置背景颜色
	
	IMAGE img;
	loadimage(&img, "12.jpg");
	putimage(0, 0, &img);//设置背景图片

	setlinecolor(BLACK);
	for (int i = 0; i < 20; i++)
	{
		line(0, i * 25, 500, i * 25);
		line(i*25, 0, i*25, 500);
		
	}
	line(500, 0, 500, 500);//画出棋盘格子

	setbkmode(0);
	settextcolor(BLACK);
	outtextxy(520, 20, "玩家1：白棋");
	outtextxy(520, 70, "玩家2：黑棋");//添加游戏备注

	mciSendString("open 55.mp3 alias bgm", NULL, 0, NULL);
	mciSendString("play bgm", NULL, 0, NULL);
	mciSendString("setaudio bgm volume to 50", NULL, 0, NULL);//添加游戏背景音乐
}

void playGame()//开始游戏
{
	MOUSEMSG Msg;
	int L = 0;
	int M = 0;
	int MAPX ;
	int MAPY;
	while (1) {
		Msg = GetMouseMsg();//捕捉鼠标位置
		//if(Msg.uMsg==WM_LBUTTONDOWN)
		//{
		//	printf("X:%d,Y:%d\n",Msg.x,Msg.y);
		//	mciSendString("open as.mp3 alias ty", NULL, 0, NULL);
		//	mciSendString("play ty", NULL, 0, NULL);
		//	mciSendString("setaudio ty volume to 900", NULL, 0, NULL);
		//}
		for (int i = 1; i < 20; i++)
		{
			for (int j = 1; j < 20; j++)
			{
				if (abs(Msg.x - j * 25) < 12 && abs(Msg.y - i * 25) < 12)
				{
					L = j * 25;
					M = i * 25;
					MAPX = j;
					MAPY = i;

				}
			}
		}
		printf("X=%d,Y=%d\n", L, M);//优化鼠标位置

		if (Msg.uMsg == WM_LBUTTONDOWN)
		{
			setfillcolor(WHITE);
			solidcircle(L, M, 10);
			p = 0;
			map[MAPX][MAPY] = 1;
		}
		if (Msg.uMsg == WM_RBUTTONDOWN)
		{
			setfillcolor(BLACK);
			solidcircle(L, M, 10);
			p = 1;
			map[MAPX][MAPY] = 2;
		}
		if (judge(MAPX, MAPY) == 1)
		{
			//区分两个玩家

			//else if (Msg.uMsg == WM_RBUTTONDOWN)
			//{
			printf("  1shengli  ");
		}
		//	mciSendString("open tss.mp3 alias py", NULL, 0, NULL);
		//	mciSendString("play py", NULL, 0, NULL);
		//	mciSendString("setaudio py volume to 900", NULL, 0, NULL);
		//}

	}
}


int judge(int MAPX, int MAPY)
{



};


int main() {
	
	initGame();
	playGame();
	getchar();
	return 0;

}
